<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: false, b: false, c: false, d: false, e: false, f: true }"
      ></navigationHeTong>
      <div class="boxsty zhiBiao" v-if="showBlock == 1">
        <!-- <div class="flex justifyContentSpaceBetween">
          <div class="tabletext">其他奖惩</div>
        </div> -->
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="合同名称">
                <el-input
                  v-model="dataForm.contractName"
                  placeholder="合同名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人姓名">
                <el-input
                  v-model="dataForm.shouyueName"
                  placeholder="受约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人岗位">
                <el-input
                  v-model="dataForm.shouyueZhiwu"
                  placeholder="受约人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人职级">
                <el-input
                  v-model="dataForm.ryZjmc"
                  placeholder="受约人职级"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="发约人姓名">
                <el-input
                  v-model="dataForm.fayueName"
                  placeholder="发约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <!-- <el-form-item label="发约人职务">
                <el-input v-model="dataForm.fayueZhiwu" placeholder="发约人职务" :clearable="true" style="width:150px"></el-input>
              </el-form-item> -->
              <!-- <el-form-item label="合同级别">
                <el-select v-model="dataForm.signLevel" placeholder="请选择合同级别" :clearable="true">
                  <el-option value="1" label="一级合同"></el-option>
                  <el-option value="2" label="二级合同"></el-option>
                  <el-option value="3" label="三级合同"></el-option>
                  <el-option value="4" label="四级合同"></el-option>
                  <el-option value="5" label="五级合同"></el-option>
                </el-select>
              </el-form-item> -->
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <!-- <div style="height: 50px; border-bottom: 1px solid #b0bde2">
          <el-button type="primary" >合同加分</el-button>
          <el-button type="primary" >提交奖惩</el-button>
          <el-button type="primary" >批量驳回</el-button>
        </div> -->
        <div class="avue-crud">
          <div class="border-top-theme">
            <div class="mt10">
              业绩合同
              <span>
                <el-radio v-model="radio" label="1">个人</el-radio>
                <el-radio v-model="radio" label="2">机构</el-radio>
              </span>
              <span
                style="margin-left: 160px"
                v-if="permissions.hetongrenwu_hetonghtxxdjb_scope"
              >
                数据范围
                <el-radio-group v-model="radioTwo">
                  <el-radio
                    v-for="(item, index) in radioTwoList"
                    :label="item.value"
                    :key="index"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </span>
              <span style="float: right">
                <el-button plain type="primary" @click="exportExcel"
                  >导出</el-button
                >
                <el-button plain type="primary" @click="handleFillAll"
                  >汇总查看</el-button
                >
                <el-button
                  plain
                  type="primary"
                  @click="okAll"
                  v-loading.fullscreen.lock="fullscreenLoading"
                  >批量同意</el-button
                >
                <!-- <el-button type="primary" @click="backAll">批量驳回</el-button> -->
                <!-- <el-button type="primary" @click="endAll">批量结束</el-button> -->
              </span>
            </div>
          </div>
          <el-table
            ref="tableRef"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            v-if="rednermsg"
            border
            v-loading="dataListLoading"
            @row-click="unfoldBtn"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="contractName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              min-width="200"
              label="合同名称"
            >
              <template slot-scope="scope">
                <span
                  @click="addOrUpdateHandle(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.contractName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 2"
              prop="jigouName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              label="机构名称"
            ></el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueCode"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人编号"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueCode.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueCode).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueCode).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueCode).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueName"
              header-align="center"
              align="center"
              min-width="120"
              label="受约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueName).slice(
                    0,
                    2
                  )"
                  :key="index + 444"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueName).length > 2 && index === 0
                    "
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人单位"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueDeptName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(
                    scope.row.shouyueDeptName
                  ).slice(0, 2)"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueDeptName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueDeptName).length > 2 &&
                      index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 1"
              prop="shouyueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人岗位"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人职级">
                  <span
                    ><i
                      @click="switchBtn(2)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人岗位</span
                  >
                </el-tooltip>
              </template>
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueZhiwu).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <span>{{ validatenull(item) ? "-" : item | ellipsis }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 2"
              prop="ryZjmc"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人职级"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人岗位">
                  <span
                    ><i
                      @click="switchBtn(1)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人职级</span
                  >
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueName"
              header-align="center"
              align="center"
              min-width="120"
              label="发约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueName).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.fayueName).length"
                    :max="9"
                    v-if="cutout(scope.row.fayueName).length > 2 && index === 0"
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="发约人岗位"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueZhiwu).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <span>{{
                    (validatenull(item) ? "-" : item) | ellipsis
                  }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="sumZbDf"
              header-align="center"
              align="center"
              label="得分"
            >
              <template slot-scope="scope">
                <el-popover placement="left" width="300" trigger="hover">
                  <div style="margin: 10px 5px">
                    <div
                      v-for="(item, index) in scope.row.suspensionList"
                      :key="index"
                    >
                      <span style="color: #0bbf4a">{{ item }}</span>
                    </div>
                  </div>

                  <div slot="reference" class="name-wrapper">
                    <span style="color: #ff3300">{{ scope.row.sumZbDf }}</span>
                  </div>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column
              prop="faqiType"
              header-align="center"
              align="center"
              label="发起类型"
              min-width="130"
              :formatter="tbFormater"
            >
            </el-table-column>
            <el-table-column
              prop="contractAuditFormater"
              header-align="center"
              align="center"
              min-width="130"
              label="合同状态"
              :formatter="contractAuditFormater"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <TianBaoTable
        ref="tianbaotable"
        v-if="showBlock == 3"
        :dataListHT="dataListHT"
        :ids="ids"
        :showType="showType"
        :tianBaoTable="tianBaoTable"
        :radio="radio"
        v-on:fnBackOldPage="fnBackOldPage"
      ></TianBaoTable>
      <!-- 结果汇总查看-->
      <HeTongZhiBiaoTable
        v-if="showBlock == 2"
        ref="hetongzhibiaotablezb"
        :hetongzhibiaoTable="hetongzhibiaoTable"
        v-on:fnBackOldPage="fnBackOldPage"
      ></HeTongZhiBiaoTable>
    </basic-container>
  </div>
</template>

<script>
import { fetchList, delObj } from "@/api/hetongrenwu/hetongqtjc";
import HeTongZhiBiaoTable from "@/views/hetongrenwu/components/hetongzhibiaohz-table.vue";
import { radioTwoList } from "@/api/hetongrenwu/hetonghtxxdjb";
import { validatenull } from "@/util/validate";
import TianBaoTable from "@/views/hetongrenwu/components/tianbao-table.vue";
import { mapGetters } from "vuex";

import {
  jghzsubmit,
  exportExcel,
  okAll,
  backAll,
  endAll,
  checkSign,
} from "@/api/hetongrenwu/hetongjghz";

export default {
  components: {
    HeTongZhiBiaoTable,
    TianBaoTable,
  },
  data() {
    return {
      dataForm: {
        key: "",
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      fullscreenLoading: false,
      radio: "1",
      radioTwo: "-1",
      showBlock: "1",
      showType: "1",
      zhibiaoForm: {},
      hetongzhibiaoTable: {
        lastPage: "qtjc",
        showSearch: false,
      },
      searchadvanced: true,
      searchheight: "0",
      radioTwoList: radioTwoList,
      streamId: Number,
      programInterface: "",
      ryZjmc: "",
      ids: [],
      dataListHT: [],
      tianBaoTable: {},
      shows: 1,
      rednermsg: true,
    };
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  watch: {
    radio(value) {
      if (value) {
        this.getDataList();
      }
    },
    radioTwo(value) {
      if (value) {
        this.getDataList();
      }
    },
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    init(
      formInfo,
      formInfoDetailed,
      formData,
      GUID,
      wfYwMain,
      wfYwStream,
      dqYwStream,
      dqTask
    ) {
      this.programInterface = dqTask.programInterface;
      this.dataForm.id = wfYwMain.ywLyid;
      this.streamId = dqYwStream.id;
      this.getDataList();
    },
    jgzbStatusFormater(row, column) {
      const jgzbStatus = row.jgzbStatus;
      if (jgzbStatus == 0) {
        return "未提交";
      } else if (jgzbStatus == 1) {
        return "填报中";
      } else if (jgzbStatus == 2) {
        return "填报已退回";
      } else if (jgzbStatus == 3) {
        return "填报已审核";
      } else if (jgzbStatus == 4) {
        return "结果审核中";
      } else if (jgzbStatus == 5) {
        return "结果审核退回";
      } else if (jgzbStatus == 6) {
        return "结果审核通过";
      } else if (jgzbStatus == 7) {
        return "已结束";
      }
    },
    statusFormater(row, column) {
      const status = row.contFillStatus;
      if (status == 0) {
        return "未填报";
      } else if (status == 1) {
        return "待预填报";
      } else if (status == 2) {
        return "已预填报";
      } else if (status == 3) {
        return "待填报";
      } else if (status == 4) {
        return "已填报";
      }
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    unfoldBtn(row) {
      row.rowshows = !row.rowshows;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      fetchList(
        Object.assign({
          fayueName: this.dataForm.fayueName,
          fayueZhiwu: this.dataForm.fayueZhiwu,
          shouyueZhiwu: this.dataForm.shouyueZhiwu,
          signLevel: this.dataForm.signLevel,
          shouyueName: this.dataForm.shouyueName,
          id: this.dataForm.id,
          current: this.pageIndex,
          size: this.pageSize,
          pageType: "htjghzsh",
          type: this.radio,
          isbenbu: this.radioTwo,
          ryZjmc: this.dataForm.ryZjmc,
          contractName: this.dataForm.contractName,
        })
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
        this.dataList.forEach((ele) => {
          ele.rowshows = true;
        });
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 编辑查看
    addOrUpdateHandle(data) {
      this.addOrUpdateVisible = true;
      this.showBlock = 2;
      this.hetongzhibiaoTable = {
        page: "qtjc",
        lastPage: "qtjc",
        showSearch: false,
        pageTitle: "汇总查看列表",
        showBackBtn: true,
        str: 1,
        hetongId: data.id,
        type: "jghzsh",
        programInterface: this.programInterface,
        streamId: this.streamId,
        taskId: data.taskId,
        type1: this.radio,
        operationType: data.faqiType,
        rows: data,
      };
      //console.log(this.hetongzhibiaoTable);
    },
    handleFillAll() {
      if (this.$refs.tableRef.selection.length < 1) {
        this.$message.closeAll();
        this.$message.error("请至少选中一条合同");
        return;
      }

      var ids = this.$refs.tableRef.selection.map((item) => {
        return item.id;
      });

      this.dataListHT = this.$refs.tableRef.selection;
      this.ids = ids;
      var taskIds = "";
      this.$refs.tableRef.selection.forEach((item) => {
        taskIds = taskIds + item.taskId + ",";
      });
      this.showBlock = 3;
      console.log(this.ids);
      this.tianBaoTable = {
        lastPage: "jghzsh",
        taskIds: taskIds,
      };
    },
    // 删除
    deleteHandle(id) {
      this.$confirm("是否确认删除ID为" + id, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delObj(id);
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    //返回原页面
    fnBackOldPage(data) {
      if (data == "返回原页面") {
        this.showBlock = 1;
        this.getDataList();
      }
    },
    //拆分数据
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    //判空
    validatenull(val) {
      return validatenull(val);
    },
    ok(row) {
      this.$confirm("是否同意该结果", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        jghzsubmit({
          id: row.id,
          jgzbStatus: 6,
        })
          .then((response) => {
            this.$message.closeAll();
            this.$message.success("提交成功!");
            this.getDataList();
          })
          .catch((err) => {
            this.$message.closeAll();
            this.$message.error("提交失败!");
          });
      });
    },
    back(row) {
      this.$confirm("是否驳回该结果", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        jghzsubmit({
          id: row.id,
          jgzbStatus: 5,
        })
          .then((response) => {
            this.$message.closeAll();
            this.$message.success("提交成功!");
            this.getDataList();
          })
          .catch((err) => {
            this.$message.closeAll();
            this.$message.error("提交失败!");
          });
      });
    },
    confirmhz(row) {
      this.$confirm("是否汇总结束", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        jghzsubmit({
          id: row.id,
          jgzbStatus: 7,
        })
          .then((response) => {
            this.$message.closeAll();
            this.$message.success("汇总合同已结束!");
            this.getDataList();
          })
          .catch((err) => {
            this.$message.closeAll();
            this.$message.error("汇总合同结束失败!");
          });
      });
    },
    exportExcel() {
      var data = this.$refs.tableRef.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
      }
      var filename = "";
      if (ids.length > 1) {
        filename = "业绩合同汇总.zip";
      } else {
        filename = "业绩合同汇总" + data[0].contractName + ".zip";
      }
      checkSign(ids).then((res) => {
        if (res.data.data == "true") {
          exportExcel({ ids: ids }).then((response) => {
            this.$message.closeAll();
            this.$message.success("导出成功!");
            let url = window.URL.createObjectURL(new Blob([response.data]));
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", filename);
            document.body.appendChild(link);
            link.click();
          });
        } else {
          this.$message.closeAll();
          this.$message.error(res.data.data);
        }
      });
    },
    //批量通过
    okAll() {
      const rows = this.$refs.tableRef.selection;
      if (rows.length > 0) {
        for (var i in rows) {
          if (rows[i].jgzbStatus == 5 || rows[i].jgzbStatus == 7) {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "当前选择数据存在已驳回或已结束",
            });
            return;
          }
        }
        this.$prompt("请对这" + rows.length + "条指标填写审批意见", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          inputValue:"暂无意见"
        }).then(({ value }) => {
          this.fullscreenLoading = true;
          okAll({ rows: rows,message:value })
            .then((res) => {
              this.$message.closeAll();
              this.$message({
                type: "info",
                message: "已通过",
              });
              this.fullscreenLoading = false;
              this.getDataList();
            })
            .catch(() => {
              this.$message.closeAll();
              this.$message({
                type: "error",
                message: "提交失败!",
              });
              this.fullscreenLoading = false;
              this.getDataList();
            })
            .catch(() => {
              this.$message.closeAll();
              this.$message({
                type: "error",
                message: "提交失败!",
              });
              this.fullscreenLoading = false;
              this.getDataList();
            });
        });
      } else {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请选择结果通过!",
        });
      }
    },
    //批量驳回
    backAll() {
      const rows = this.$refs.tableRef.selection;
      if (rows.length > 0) {
        for (var i in rows) {
          //console.log(rows[i])
          //console.log()
          if (rows[i].jgzbStatus == 6 || rows[i].jgzbStatus == 7) {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "当前选择数据存在已通过或已结束",
            });
            return;
          }
        }
        this.$confirm("是否要驳回" + rows.length + "条指标?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            backAll(rows)
              .then((res) => {
                this.$message.closeAll();
                this.$message({
                  type: "info",
                  message: res.data.data + "条结果已驳回",
                });
                this.getDataList();
              })
              .catch(() => {
                this.$message.closeAll();
                this.$message({
                  type: "error",
                  message: "提交失败!",
                });
                this.getDataList();
              });
          })
          .catch(() => {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "已取消提交",
            });
          });
      } else {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请选择结果驳回!",
        });
      }
    },
    //批量结束
    endAll() {
      const rows = this.$refs.tableRef.selection;
      if (rows.length > 0) {
        for (var i in rows) {
          //console.log(rows[i])
          //console.log()
          if (rows[i].jgzbStatus != 6) {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "当前选择数据未通过无法结束",
            });
            return;
          }
        }
        this.$confirm("是否要结束" + rows.length + "条结果?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            endAll(rows)
              .then((res) => {
                this.$message.closeAll();
                this.$message({
                  type: "info",
                  message: res.data.data + "条结果已结束",
                });
                this.getDataList();
              })
              .catch(() => {
                this.$message.closeAll();
                this.$message({
                  type: "error",
                  message: "提交失败!",
                });
                this.getDataList();
              });
          })
          .catch(() => {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "已取消提交",
            });
          });
      } else {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请选择结果结束!",
        });
      }
    },
    tbFormater(row, column) {
      const status = row.faqiType;
      if (status == 0) {
        return "预填报";
      } else if (status == 1) {
        return "实际填报";
      }
    },
    contractAuditFormater(row, column) {
      const status = row.contractAuditStatus;
      if (status == 10) {
        return "已归档";
      } else if (status == 11) {
        return "填报中";
      } else if (status == 12) {
        return "结果审核中";
      } else if (status == 13) {
        return "结果汇总完成";
      } else if (status == 14) {
        return "领导审核中";
      } else if (status == 15) {
        return "领导审核完成";
      } else if (status == 16) {
        return "已结束";
      }
    },
    //切换显示受约人职务和受约人职级
    switchBtn(e) {
      this.shows = e;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
  },
};
</script>
